package com.teamtgv.shareshark;

import com.teamtgv.shareshark.R;

import android.app.Activity;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.Display;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;

public class ImagePopupActivity extends Activity {

	public static final String IMAGE = "image";
	private ImageView dialog;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_image_popup);
		
		dialog = (ImageView)findViewById(R.id.popupImage);
		
		Bitmap picture = (Bitmap) getIntent().getParcelableExtra(IMAGE);
		
		Display display = getWindowManager().getDefaultDisplay();
			
		int scaledWidth = display.getWidth();
		int scaledHeight = (int) (picture.getHeight() * ((float)scaledWidth / picture.getWidth()));
		dialog.setImageBitmap(Bitmap.createScaledBitmap(picture, scaledWidth, scaledHeight, false));
		dialog.setClickable(true);

        //finish the activity (dismiss the image dialog) if the user clicks 
        //anywhere on the image
        dialog.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				finish();
			}
		});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		//getMenuInflater().inflate(R.menu.image_popup, menu);
		return false;
	}

}
